package com.gongzhiyun.springboot3test.mapper.novel;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gongzhiyun.springboot3test.entity.novel.NovelList;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface NovelListMapper extends BaseMapper<NovelList> {

    //根据名称查询小说
    @Select("select  * from novel_list where novel_title=#{novelTitle}")
    NovelList queryByTitle(String novelTitle);

    //更新小说的评分和总章节数
    @Update("update novel_list set rating=#{rating},total_chapters=#{chapter} where id=#{id}")
    int updateRatingAndChapter(Double rating,Integer chapter,Integer id);

    //查询最后一个的小说id
    @Select("select  id from novel_list order by id desc limit 1")
    Integer getLastId();

}
